package cn.springmvc.util;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpSession;

public class SessionManager {
	private Map<String, HttpSession> sessionMap;
	static private SessionManager instance;
	
	private SessionManager(){
		sessionMap = new HashMap<String, HttpSession>();
	}
	
	public static SessionManager getInstance(){
		if(instance == null){
			instance = new SessionManager();
		}
		return instance;
	}
	
	public void addSession(String sessionId, HttpSession httpSession){
		this.sessionMap.put(sessionId, httpSession);
	}
	
	public HttpSession getSessionById(String sessionId){
		return this.sessionMap.get(sessionId);
	}
	
	public void removeSessionById(String sessionId){
		this.sessionMap.remove(sessionId);
	}
}
